/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork;

/**
 *
 * @author ASUS
 */
public class Rectangle {
    protected int Top;      // Y
    protected int Bottom;   // Y + Height
    protected int Right;    // X + Width
    protected int Left;     // X

    public Rectangle(int _X, int _Y, int _SizeX, int _SizeY) {
        Top     = _Y;
        Bottom  = _Y + _SizeY;
        Right   = _X + _SizeX;
        Left    = _X;
    }
    
    public boolean  Intersects(Rectangle _Rect){        
                
        int ty = (Math.abs (Top - _Rect.Bottom)> Math.abs (Bottom - _Rect.Top) )
                ? Math.abs (Top - _Rect.Bottom) : Math.abs (Bottom - _Rect.Top);
        
        
        int tx = (Math.abs (Left - _Rect.Right)> Math.abs (Right - _Rect.Left) )
                ? Math.abs (Left - _Rect.Right) : Math.abs (Right - _Rect.Left);
        
        return ((tx < ((Right - Left) + (_Rect.Right - _Rect.Left))) && 
                (ty < ((Bottom - Top) + (_Rect.Bottom - _Rect.Top))));        
    }     
     public boolean Intersects(Point _Point){
         return((_Point.X<= Right) && (_Point.X>= Left) && (_Point.Y >= Top) && (_Point.Y <= Bottom));
     }
}